home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 004 / sunset.bas (.txt) < prev    next >
Encoding:
GW-BASIC  |  1984-04-24  |  2.7 KB  |  85 lines

  1. 10  REM One note regarding azimuth angles: In the SOUTHERN hemisphere,
  2. 20  REM this program assumes that the South Pole is zero degrees, and
  3. 30  REM the azimuth angle is measured COUNTER-clockwise through East.
  4. 40  REM Therefore, an azimuth angle of 108 degrees is NORTH of East.
  5. 50  REM When Lat and Long are input, use a negative value for Southern
  6. 60  REM Latitudes and for Eastern Longitudes.
  7. 70  REM ----------------- Program Begins ---------------------------
  8. 80  CLS
  9. 90  PRINT"This program finds the declination of the sun, the equation"
  10. 100  PRINT"of time, the azimuth angles of sunrise and sunset, and the"
  11. 110  PRINT"times of sunrise and sunset for any point on earth."
  12. 120  PRINT
  13. 130  PRINT"Input eastern longitudes and southern latitudes as NEGATIVE."
  14. 140  PRINT
  15. 150  PRINT
  16. 160  REM
  17. 170  REM
  18. 180  DIM N(12)
  19. 190  PL=3.14159/26:J=57.2958
  20. 200  INPUT"ENTER LATITUDE (FORMAT DD.MM)";D1
  21. 210  INPUT"ENTER LONGITUDE (FORMAT DD.MM)";D2
  22. 220  GOSUB 780
  23. 230  LA = D1
  24. 240  IF LA < 0 THEN LA = LA + 180
  25. 250  IF D2 < 0 THEN D2 = D2 + 360
  26. 260  LO = FIX(D2/15)*15 :REM finds time zone beginning
  27. 270  TD=(D2-LO)/15
  28. 280  INPUT"ENTER MONTH,DAY (11,25)";M,DA
  29. 290  FOR I=1 TO 12: READ N(I):NEXT I
  30. 300  DATA 0,31,59,90,120,151
  31. 310  DATA 181,212,243,273,304,334
  32. 320  X=(N(M)+DA)/7
  33. 330  REM
  34. 340  D=0.456-22.195*COS(PL*X)-0.43*COS(2*PL*X)-0.156*COS(3*PL*X)+3.83*SIN(PL*X)+0.06*SIN(2*PL*X)-0.082*SIN(3*PL*X)
  35. 350  REM
  36. 360  PRINT
  37. 370  PRINT"DECLINATION OF SUN:";
  38. 380  PRINT USING"###.#";D;
  39. 390  PRINT" DEGREES"
  40. 400  E=0.008+0.51*COS(PL*X)-3.197*COS(2*PL*X)-0.106*COS(3*PL*X)-0.15*COS(4*PL*X)-7.317*SIN(PL*X)-9.471*SIN(2*PL*X)-0.391*SIN(3*PL*X)-0.242*SIN(4*PL*X)
  41. 410  REM
  42. 420  PRINT"EQUATION OF TIME:";
  43. 430  PRINT USING"###.#";E;
  44. 440  PRINT" MINUTES"
  45. 450  CL=COS(LA/J):SD=SIN(D/J):CD=COS(D/J):Y=SD/CL
  46. 460  IF ABS(Y)=>1 THEN PRINT"NO SUNRISE OR SUNSET":END
  47. 470  Z = 90 - J*ATN(Y/SQR(1-Y*Y))
  48. 480  PRINT"AZIMUTH OF SUNRISE:";
  49. 490  PRINT USING"####.#";ABS(Z);
  50. 500  PRINT" DEGREES"
  51. 510  PRINT"AZIMUTH OF SUNSET: ";
  52. 520  PRINT USING"####.#";360-ABS(Z);
  53. 530  PRINT" DEGREES"
  54. 540  ST=SIN(Z/J)/CD
  55. 550  IF ABS(ST)>=1 THEN T=6:TT=6:GOTO 590
  56. 560  CT=SQR(1-ST*ST)
  57. 570  T=J/15*ATN(ST/CT)
  58. 580  TT=T
  59. 590  IF D<0 AND LA<90 THEN T=12-T:TT=T
  60. 600  IF D>0 AND LA>90 THEN T=12-T: TT=T
  61. 610  T=T+TD-E/60-0.04
  62. 620  GOSUB 690
  63. 630  PRINT"TIME OF SUNRISE:";T1$;":";T2$;" ";T$;"L.T. ";GM$;":";T2$;" GM"
  64. 640  T=12-TT:T=T+TD-E/60+0.04
  65. 650  CNT=1
  66. 660  GOSUB 690
  67. 670  PRINT"TIME OF SUNSET: ";T1$;":";T2$;" ";T$;"L.T. ";GM$;":";T2$;" GM"
  68. 680  END
  69. 690  T1=INT(T):T2=T-T1:T1$=STR$(T1):T2=INT((T2*600+5)/10)
  70. 700  T2$=STR$(T2):T2$=RIGHT$(T2$,LEN(T2$)-1)
  71. 710  IF INT(T2)<10 THEN T2$="0"+T2$
  72. 720  GM = FIX(D2/15) :REM calculate difference between GM and local time
  73. 730  IF CNT = 0 THEN GM = VAL(T1$)+GM :REM GMT for sunrise
  74. 740  IF CNT > 0 THEN GM = VAL(T1$)+12+GM :REM GMT for sunset
  75. 750  IF GM +(VAL(T2$)/60)> 24 THEN GM = GM - 24
  76. 760  GM$ = STR$(GM) :GM$ = RIGHT$("0"+GM$,2)
  77. 770  RETURN
  78. 780  REM This subroutine converts DD.MM input to DD.DD
  79. 790  DEGTMP = (ABS(D1)-ABS(FIX(D1))) *100/60
  80. 800  D1 = (FIX(ABS(D1))+DEGTMP)*SGN(D1)
  81. 810  DEGTMP = (ABS(D2)-ABS(FIX(D2))) *100/60
  82. 820  D2 = (FIX(ABS(D2))+DEGTMP)*SGN(D2)
  83. 830  RETURN
  84. 840  END
  85.